home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 May (DVD) / Macworld Resource DVD May 2003.toast / Data / Software / Bonus / Database / mysql-max-3.23.55.sit / mysql-max-3.23.55-apple-darwi.1 / include / thr_alarm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-01-21  |  2.7 KB  |  113 lines  |  [TEXT/CWIE]

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    
  3.    This library is free software; you can redistribute it and/or
  4.    modify it under the terms of the GNU Library General Public
  5.    License as published by the Free Software Foundation; either
  6.    version 2 of the License, or (at your option) any later version.
  7.    
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.    
  13.    You should have received a copy of the GNU Library General Public
  14.    License along with this library; if not, write to the Free
  15.    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  16.    MA 02111-1307, USA */
  17.  
  18. /* Prototypes when using thr_alarm library functions */
  19.  
  20. #ifndef _thr_alarm_h
  21. #define _thr_alarm_h
  22. #ifdef    __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26. #ifndef USE_ALARM_THREAD
  27. #define USE_ONE_SIGNAL_HAND        /* One must call process_alarm */
  28. #endif
  29. #ifdef HAVE_LINUXTHREADS
  30. #define THR_CLIENT_ALARM SIGALRM
  31. #else
  32. #define THR_CLIENT_ALARM SIGUSR1
  33. #endif
  34. #ifdef HAVE_rts_threads
  35. #undef USE_ONE_SIGNAL_HAND
  36. #define USE_ALARM_THREAD
  37. #define THR_SERVER_ALARM SIGUSR1
  38. #else
  39. #define THR_SERVER_ALARM SIGALRM
  40. #endif
  41.  
  42. #if defined(DONT_USE_THR_ALARM)
  43.  
  44. #define USE_ALARM_THREAD
  45. #undef USE_ONE_SIGNAL_HAND
  46.  
  47. typedef struct st_thr_alarm_entry
  48. {
  49.   uint crono;
  50. } thr_alarm_entry;
  51.  
  52. #define thr_alarm_init(A)   (A)->crono=0
  53. #define thr_alarm_in_use(A) (A)->crono
  54. #define init_thr_alarm(A)
  55. #define thr_alarm_kill(A)
  56. #define end_thr_alarm()
  57. #define thr_alarm(A,B) (((A)->crono=1)-1)
  58. #define thr_got_alarm(A) (A)->crono
  59. #define thr_end_alarm(A)
  60.  
  61. #else
  62. #if defined(__WIN__)
  63. typedef struct st_thr_alarm_entry
  64. {
  65.   rf_SetTimer crono;
  66. } thr_alarm_entry;
  67.  
  68. #elif defined(__EMX__) || defined(OS2)
  69.  
  70. typedef struct st_thr_alarm_entry
  71. {
  72.   uint crono;
  73.   uint event;
  74. } thr_alarm_entry;
  75.  
  76. #else /* System with posix threads */
  77.  
  78. typedef int thr_alarm_entry;
  79.  
  80. #define thr_got_alarm(thr_alarm) (**(thr_alarm))
  81.  
  82. #endif /* __WIN__ */
  83.  
  84. typedef thr_alarm_entry* thr_alarm_t;
  85.  
  86. typedef struct st_alarm {
  87.   ulong expire_time;
  88.   thr_alarm_entry alarmed;        /* set when alarm is due */
  89.   pthread_t thread;
  90.   my_bool malloced;
  91. } ALARM;
  92.  
  93. #define thr_alarm_init(A) (*(A))=0
  94. #define thr_alarm_in_use(A) (*(A)!= 0)
  95. void init_thr_alarm(uint max_alarm);
  96. bool thr_alarm(thr_alarm_t *alarmed, uint sec, ALARM *buff);
  97. void thr_alarm_kill(pthread_t thread_id);
  98. void thr_end_alarm(thr_alarm_t *alarmed);
  99. void end_thr_alarm(void);
  100. sig_handler process_alarm(int);
  101. #ifndef thr_got_alarm
  102. bool thr_got_alarm(thr_alarm_t *alrm);
  103. #endif
  104.  
  105.  
  106. #endif /* DONT_USE_THR_ALARM */
  107.  
  108. #ifdef    __cplusplus
  109. }
  110. #endif /* __cplusplus */
  111. #endif /* _thr_alarm_h */
  112.  
  113.